home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dirut / dosdir21.zip / EXAMPLE3.C < prev    next >
C/C++ Source or Header  |  1994-06-24  |  526b  |  28 lines

  1. /*
  2.  *  EXAMPLE3.C - Example program uses POSIX directory functions
  3.  *
  4.  *    usage:  example3 [pathname]
  5.  *
  6.  *  Modification history:
  7.  *   V1.0  22-Jun-94, J Mathews  Original version.
  8.  */
  9.  
  10. #include "dirent.h"
  11.  
  12. main(argc, argv)
  13.      int argc;
  14.      char** argv;
  15. {
  16.  DIR* dirp;
  17.  struct dirent* dp;
  18.  char *path = (argc==1) ? DIR_CUR : argv[1];
  19.  
  20.  printf("Directory of %s\n\n", path);
  21.  dirp = opendir(path);
  22.  while ((dp = readdir(dirp)) != NULL)
  23.    {
  24.      printf("%-40s", dp->d_name);
  25.    }
  26.  closedir(dirp);
  27. }
  28.